package org.jsbd.boss.service.impl;

import java.util.List;

import org.jsbd.boss.dao.IMiguVideoRetentAddConfigDao;
import org.jsbd.boss.dao.IMiguVideoRetentAddTimerDao;
import org.jsbd.boss.domian.MiguVideoRetentAddConfig;
import org.jsbd.boss.domian.MiguVideoRetentAddTimer;
import org.jsbd.boss.service.IMiguVideoRetentAddTimerService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("miguVideoRetentAddTimerService")
public class MiguVideoRetentAddTimerServiceImpl implements IMiguVideoRetentAddTimerService {

	@Autowired
	private IMiguVideoRetentAddTimerDao miguVideoRetentAddTimerDao;

	@Autowired
	private IMiguVideoRetentAddConfigDao miguVideoRetentAddConfigDao;

	@Override
	public void save(List<MiguVideoRetentAddTimer> list) {
		miguVideoRetentAddTimerDao.save(list);
	}

	@Override
	public List<MiguVideoRetentAddTimer> getList(MiguVideoRetentAddTimer miguVideoRetentAddTimer) {
		return miguVideoRetentAddTimerDao.getList(miguVideoRetentAddTimer);
	}

	@Override
	public void delete(List<Integer> ids) {
		miguVideoRetentAddTimerDao.delete(ids);
	}

	@Override
	public void deleteByMiguVideoId(Integer miguVideoId) {
		miguVideoRetentAddTimerDao.deleteByMiguVideoId(miguVideoId);
	}

	@Override
	public List<MiguVideoRetentAddTimer> getIsDoList() {
		return miguVideoRetentAddTimerDao.getIsDoList();
	}

	@Override
	public int updateToConfig(MiguVideoRetentAddTimer timer) {

		MiguVideoRetentAddConfig config = new MiguVideoRetentAddConfig();
		config.setMiguVideoId(timer.getMiguVideoId());
		config.setRetentMonth(timer.getRetentMonth());
		config.setExecTimes(timer.getExecTimes());
		config.setTaskNum(timer.getTaskNum());

		miguVideoRetentAddConfigDao.updateTaskNum(config);

		return miguVideoRetentAddTimerDao.updateIsDo(timer.getId());
	}
}
